package com.example.treasureadmin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.treasureadmin.mapper.ManagerMapper;
import com.example.treasureadmin.model.ManagerModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManagerService {

    @Autowired
    private ManagerMapper managerMapper;

    public String login(String username, String password){
        QueryWrapper<ManagerModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        ManagerModel managerModel = managerMapper.selectOne(queryWrapper);
        if (managerModel == null){
            return "101";
        }
        else{
            if (!managerModel.getPassword().equals(password)){
                return "101";
            }
        }
        return "200";
    }

    public ManagerModel relogin(String username){
        ManagerModel managerModel = managerMapper.selectById(username);
        managerModel.setPassword("");
        return managerModel;
    }
}
